package 牛客小白月赛94;

import java.util.Scanner;

public class B小苯的好数组 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n + 10];
		
		for(int i = 1; i <= n; i ++ ) {
			a[i] = sc.nextInt();
		}
		int t = 0;
		
		for(int i = n; i >= 1; i -- ) {
			if(i != 1 && a[i] < a[i - 1]) {
				t = 1;
				break;
			}
		}
		//小思维
		if(t == 1) {
			System.out.print(n);
		} else {
			System.out.print(0);
		}
	}
}
